import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SellproVO, SellproForm, SellproQuery } from '@/api/trace/sellpro/types';

/**
 * 查询溯源产品列表
 * @param query
 * @returns {*}
 */

export const listSellpro = (query?: SellproQuery): AxiosPromise<SellproVO[]> => {
  return request({
    url: '/trace/sellpro/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询溯源产品详细
 * @param sellproId
 */
export const getSellpro = (sellproId: string | number): AxiosPromise<SellproVO> => {
  return request({
    url: '/trace/sellpro/' + sellproId,
    method: 'get'
  });
};

/**
 * 新增溯源产品
 * @param data
 */
export const addSellpro = (data: SellproForm) => {
  return request({
    url: '/trace/sellpro',
    method: 'post',
    data: data
  });
};

/**
 * 修改溯源产品
 * @param data
 */
export const updateSellpro = (data: SellproForm) => {
  return request({
    url: '/trace/sellpro',
    method: 'put',
    data: data
  });
};

/**
 * 删除溯源产品
 * @param sellproId
 */
export const delSellpro = (sellproId: string | number | Array<string | number>) => {
  return request({
    url: '/trace/sellpro/' + sellproId,
    method: 'delete'
  });
};
